//
//  MVC-C.m
//  DesignPattern
//
//  Created by jun on 2021/4/16.
//

#import "MVC-C.h"
#import "RequestManager.h"
#import "MVC-M.h"
#import "MVC-V.h"

@interface MVC_C ()

@property MVC_M *model;
@property MVC_V *mvc_v;

@end

@implementation MVC_C

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self initViews];
}

-(void)initViews{
    self.mvc_v = [[MVC_V alloc] initWithFrame:self.view.frame];
    self.mvc_v.backgroundColor = [UIColor yellowColor];
    [self.view addSubview:self.mvc_v];
}

#pragma mark 也有将这个放到model层 model刷新view的
-(void)getUserData{
    __weak typeof(self) wSelf = self;
    [RequestManager getUserData:^(BOOL success, NSDictionary * _Nonnull dic, NSString * _Nonnull msg, NSError * _Nonnull error) {
        __strong typeof(wSelf) sSelf = wSelf;
        if (success) {
            if ([dic isKindOfClass:[NSDictionary class]]&&[dic[@"data"] isKindOfClass:[NSDictionary class]]) {
                MVC_M *model = [MVC_M new];
                model.title =dic[@"data"][@"title"];
                model.desc =dic[@"data"][@"desc"];
                sSelf.model = model;
            }
        }
    }];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
